package com.guigu.youxuan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.youxuan.common.utils.PageUtils;
import com.guigu.youxuan.mapper.WarehouseMapper;
import com.guigu.youxuan.pojo.GoodsInfo;
import com.guigu.youxuan.pojo.SupplierProduct;
import com.guigu.youxuan.pojo.Warehouse;
import com.guigu.youxuan.service.IWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author liweixin
 * @since 2024-05-15
 */
@Service
public class WarehouseServiceImpl extends ServiceImpl<WarehouseMapper, Warehouse> implements IWarehouseService {
        @Autowired
      private  WarehouseMapper warehouseMapper;
    /**
     * 分页查询所有仓库信息
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<Warehouse> WarehouseListPage(int pageNo, int pageSize) {
        QueryWrapper<Warehouse> wrapper=new QueryWrapper<>();
        wrapper.eq("check_tag","S001-3");
        PageHelper.startPage(pageNo,pageSize);
        List<Warehouse> warehouses=warehouseMapper.Page(wrapper);
        PageInfo<Warehouse> pageInfo=new PageInfo<>(warehouses);
        return pageInfo;
    }

    /**
     * 查询未复核的仓库信息
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<Warehouse> WarehouseFuhePage(int pageNo, int pageSize) {
        QueryWrapper<Warehouse> queryWrapper=new QueryWrapper<>();
        //审核状态: 待审核
        queryWrapper.eq("check_tag","S001-1");
        PageHelper.startPage(pageNo,pageSize);
        List<Warehouse> warehouses=warehouseMapper.list(queryWrapper);
        PageInfo<Warehouse> pageInfo=new PageInfo<>(warehouses);
        return pageInfo;
    }
    /**
     * 仓库禁用/启用
     * @param warehouse
     * @return
     */
    @Override
    public void switchStatus(Warehouse warehouse) {
        if(warehouse != null){
            this.updateById(warehouse);
        }
    }

    @Override
    public List<Warehouse> queryWarehouse() {
        List<Warehouse> list = this.list();
        return list;
    }
    /**
     * 根据仓库表id查询对应的仓库信息
     * @param id
     * @return
     */
    @Override
    public Warehouse getByListId(int id) {
        Warehouse warehouse=warehouseMapper.getByIdPage(id);
        return warehouse;
    }
}
